/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package trefliq.persistence.entity;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.*;
//import javax.validation.constraints.NotNull;
//import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Adam Gojdas
 */
@Entity
@Table(name = "CREDIT")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Credit.findAll", query = "SELECT c FROM Credit c"),
    @NamedQuery(name = "Credit.findById", query = "SELECT c FROM Credit c WHERE c.id = :id"),
    @NamedQuery(name = "Credit.findByCreditinmovie", query = "SELECT c FROM Credit c WHERE c.creditinmovie = :creditinmovie")})
public class Credit implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
//    @NotNull
    @Column(name = "ID", nullable = false)
    @GeneratedValue(strategy=GenerationType.TABLE, generator="CREDIT")
    private Long id;
    @Basic(optional = false)
//    @NotNull
//    @Size(min = 1, max = 50)
    @Column(name = "CREDITINMOVIE", nullable = false, length = 50)
    private String creditinmovie;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "credit")
    private Collection<MovieCredit> movieCreditCollection;

    public Credit() {
    }

    public Credit(Long id) {
        this.id = id;
    }

    public Credit(Long id, String creditinmovie) {
        this.id = id;
        this.creditinmovie = creditinmovie;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getCreditinmovie() {
        return creditinmovie;
    }

    public void setCreditinmovie(String creditinmovie) {
        this.creditinmovie = creditinmovie;
    }

    @XmlTransient
    public Collection<MovieCredit> getMovieCreditCollection() {
        return movieCreditCollection;
    }

    public void setMovieCreditCollection(Collection<MovieCredit> movieCreditCollection) {
        this.movieCreditCollection = movieCreditCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Credit)) {
            return false;
        }
        Credit other = (Credit) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "se554.grp3.adg.Credit[ id=" + id + " ]";
    }
    
}
